/*
 * @Author: szx
 * @Date: 2022-03-31 12:42:41
 * @LastEditTime: 2022-03-31 12:52:30
 * @Description:
 * @FilePath: \leetcode\剑指offerII\005\005.js
 */
/**
 * @param {string[]} words
 * @return {number}
 */
var maxProduct = function (words) {
    const mask = new Array(words.length).fill(0);
    for (let i = 0; i < words.length; i++) {
        for (let w of words[i]) {
            mask[i] |= 1 << (w.charCodeAt() - 97);
        }
    }
    let res = 0;
    for (let i = 0; i < words.length - 1; i++) {
        for (let j = i + 1; j < words.length; j++) {
            if ((mask[i] & mask[j]) == 0) {
                res = Math.max(res, words[i].length * words[j].length);
            }
        }
    }
    return res;
};
